/*
 * Created on 2006-10-10
 *
 * To change the template for this generated file go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
package com.hitrust.gs.lib.db;

import java.io.*;
import java.math.BigDecimal;
import java.net.URL;
import java.sql.*;
import java.util.Calendar;
import com.hitrust.gs.lib.*;

/**
 * @author Administrator
 *
 * To change the template for this generated type comment go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
public class MyPrepareStatement implements PreparedStatement {

	private PreparedStatement mPst=null;
	
	private MyConnection mCon ;
	
	/**
	 * 
	 * @param pst
	 */
	public MyPrepareStatement(MyConnection con,PreparedStatement pst){
		mPst=pst;
		mCon = con ;
		}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#executeQuery()
	 */
	public ResultSet executeQuery() throws SQLException 
	{
		// TODO Auto-generated method stub
		try
		{
			MyResultSet rs= new MyResultSet(mPst.executeQuery());	
			SQLLogger.log("Success");
			return rs;
		}
		catch(SQLException e)
		{
			GSBaseDAO.pushSQLError(e.toString());
			SQLLogger.log("error:"+e.toString());
			throw e ;
		}
	}
	/* (non-Javadoc)
	 * @see java.sql.Statement#close()
	 */
	public void close() throws SQLException 
	{
		mPst.close();
	}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#executeUpdate()
	 */
	public int executeUpdate() throws SQLException 
	{
		try
		{
			int ret =  mPst.executeUpdate();
			SQLLogger.log("Success");
			return ret ;
		}
		catch(SQLException e)
		{
			GSBaseDAO.pushSQLError(e.toString());
			SQLLogger.log("error:"+e.toString());
			throw e ;
		}
		
		
	}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#setNull(int, int)
	 */
	public void setNull(int parameterIndex, int sqlType) throws SQLException {
		// TODO Auto-generated method stub
		mPst.setNull( parameterIndex, sqlType);
	}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#setBoolean(int, boolean)
	 */
	public void setBoolean(int parameterIndex, boolean x) throws SQLException {
		// TODO Auto-generated method stub
		mPst.setBoolean(parameterIndex,  x);
	}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#setByte(int, byte)
	 */
	public void setByte(int parameterIndex, byte x) throws SQLException {
		// TODO Auto-generated method stub
		mPst.setByte( parameterIndex,  x);
	}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#setShort(int, short)
	 */
	public void setShort(int parameterIndex, short x) throws SQLException {
		// TODO Auto-generated method stub
		mPst.setShort( parameterIndex, x);
	}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#setInt(int, int)
	 */
	public void setInt(int parameterIndex, int x) throws SQLException {
		// TODO Auto-generated method stub
		mPst.setInt(parameterIndex,  x);
	}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#setLong(int, long)
	 */
	public void setLong(int parameterIndex, long x) throws SQLException {
		// TODO Auto-generated method stub
		mPst.setLong( parameterIndex, x);
	}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#setFloat(int, float)
	 */
	public void setFloat(int parameterIndex, float x) throws SQLException {
		// TODO Auto-generated method stub
		mPst.setFloat( parameterIndex, x);
	}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#setDouble(int, double)
	 */
	public void setDouble(int parameterIndex, double x) throws SQLException {
		// TODO Auto-generated method stub
		mPst.setDouble( parameterIndex,  x);
	}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#setBigDecimal(int, java.math.BigDecimal)
	 */
	public void setBigDecimal(int parameterIndex, BigDecimal x)
		throws SQLException {
		// TODO Auto-generated method stub
		mPst.setBigDecimal(parameterIndex,  x);
	}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#setString(int, java.lang.String)
	 */
	public void setString(int parameterIndex, String x) throws SQLException {
		// TODO Auto-generated method stub
		mPst.setString( parameterIndex,  x);
	}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#setBytes(int, byte[])
	 */
	public void setBytes(int parameterIndex, byte[] x) throws SQLException {
		// TODO Auto-generated method stub
		mPst.setBytes( parameterIndex,  x);
	}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#setDate(int, java.sql.Date)
	 */
	public void setDate(int parameterIndex, Date x) throws SQLException {
		// TODO Auto-generated method stub
		mPst.setDate( parameterIndex, x);
	}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#setTime(int, java.sql.Time)
	 */
	public void setTime(int parameterIndex, Time x) throws SQLException {
		// TODO Auto-generated method stub
		mPst.setTime( parameterIndex, x);
	}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#setTimestamp(int, java.sql.Timestamp)
	 */
	public void setTimestamp(int parameterIndex, Timestamp x)
		throws SQLException {
		// TODO Auto-generated method stub
		mPst.setTimestamp(parameterIndex,  x);
	}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#setAsciiStream(int, java.io.InputStream, int)
	 */
	public void setAsciiStream(int parameterIndex, InputStream x, int length)
		throws SQLException {
		// TODO Auto-generated method stub
		mPst.setAsciiStream( parameterIndex,  x,  length);
	}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#setUnicodeStream(int, java.io.InputStream, int)
	 */
	public void setUnicodeStream(int parameterIndex, InputStream x, int length)
		throws SQLException {
		// TODO Auto-generated method stub
		mPst.setUnicodeStream(parameterIndex,  x,  length);
	}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#setBinaryStream(int, java.io.InputStream, int)
	 */
	public void setBinaryStream(int parameterIndex, InputStream x, int length)
		throws SQLException {
		// TODO Auto-generated method stub
		mPst.setBinaryStream(parameterIndex, x, length);
	}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#clearParameters()
	 */
	public void clearParameters() throws SQLException {
		// TODO Auto-generated method stub
		mPst.clearParameters();
	}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#setObject(int, java.lang.Object, int, int)
	 */
	public void setObject(
		int parameterIndex,
		Object x,
		int targetSqlType,
		int scale)
		throws SQLException {
		// TODO Auto-generated method stub
		mPst.setObject(
		 parameterIndex,
		 x,
		targetSqlType,
		 scale);
	}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#setObject(int, java.lang.Object, int)
	 */
	public void setObject(int parameterIndex, Object x, int targetSqlType)
		throws SQLException {
		// TODO Auto-generated method stub
		mPst.setObject(parameterIndex,  x, targetSqlType);
	}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#setObject(int, java.lang.Object)
	 */
	public void setObject(int parameterIndex, Object x) throws SQLException {
		// TODO Auto-generated method stub
		mPst.setObject(parameterIndex, x);
	}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#execute()
	 */
	public boolean execute() throws SQLException 
	{
		try
		{
			boolean ret = mPst.execute();
			SQLLogger.log("Success");
			return ret ;
		}
		catch(SQLException e)
		{
			GSBaseDAO.pushSQLError(e.toString());
			throw e ;
		}
		// TODO Auto-generated method stub
		
	}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#addBatch()
	 */
	public void addBatch() throws SQLException 
	{
		try
		{
			mPst.addBatch();
		}
		catch(SQLException e)
		{
			GSBaseDAO.pushSQLError(e.toString());
			SQLLogger.log("error:"+e.toString());
			throw e ;
		}
		// TODO Auto-generated method stub
		
	}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#setCharacterStream(int, java.io.Reader, int)
	 */
	public void setCharacterStream(
		int parameterIndex,
		Reader reader,
		int length)
		throws SQLException {
		// TODO Auto-generated method stub
		mPst.setCharacterStream(
		 parameterIndex,
		 reader,
		 length);
	}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#setRef(int, java.sql.Ref)
	 */
	public void setRef(int i, Ref x) throws SQLException {
		// TODO Auto-generated method stub
		mPst.setRef( i,  x);
	}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#setBlob(int, java.sql.Blob)
	 */
	public void setBlob(int i, Blob x) throws SQLException {
		// TODO Auto-generated method stub
		mPst.setBlob( i,  x);
	}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#setClob(int, java.sql.Clob)
	 */
	public void setClob(int i, Clob x) throws SQLException {
		// TODO Auto-generated method stub
		mPst.setClob( i,  x);
	}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#setArray(int, java.sql.Array)
	 */
	public void setArray(int i, Array x) throws SQLException {
		// TODO Auto-generated method stub
		mPst.setArray( i,  x);
	}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#getMetaData()
	 */
	public ResultSetMetaData getMetaData() throws SQLException {
		// TODO Auto-generated method stub
		return mPst.getMetaData();
	}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#setDate(int, java.sql.Date, java.util.Calendar)
	 */
	public void setDate(int parameterIndex, Date x, Calendar cal)
		throws SQLException {
		// TODO Auto-generated method stub
		mPst.setDate( parameterIndex,  x,  cal);
	}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#setTime(int, java.sql.Time, java.util.Calendar)
	 */
	public void setTime(int parameterIndex, Time x, Calendar cal)
		throws SQLException {
		// TODO Auto-generated method stub
		mPst.setTime( parameterIndex,  x,  cal);
	}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#setTimestamp(int, java.sql.Timestamp, java.util.Calendar)
	 */
	public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal)
		throws SQLException {
		// TODO Auto-generated method stub
		mPst.setTimestamp( parameterIndex,  x,  cal);
	}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#setNull(int, int, java.lang.String)
	 */
	public void setNull(int paramIndex, int sqlType, String typeName)
		throws SQLException {
		// TODO Auto-generated method stub
		mPst.setNull( paramIndex,  sqlType,  typeName);
	}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#setURL(int, java.net.URL)
	 */
	public void setURL(int parameterIndex, URL x) throws SQLException {
		// TODO Auto-generated method stub
		mPst.setURL( parameterIndex,  x) ;
	}

	/* (non-Javadoc)
	 * @see java.sql.PreparedStatement#getParameterMetaData()
	 */
	public ParameterMetaData getParameterMetaData() throws SQLException {
		// TODO Auto-generated method stub
		return mPst.getParameterMetaData();
	}

	/* (non-Javadoc)
	 * @see java.sql.Statement#executeQuery(java.lang.String)
	 */
	public ResultSet executeQuery(String sql) throws SQLException 
	{
		try
		{
			SQLLogger.log(sql);
			MyResultSet rs= new MyResultSet(mPst.executeQuery( sql));
			SQLLogger.log("Success");
			return rs;
		}
		catch(SQLException e)
		{
			GSBaseDAO.pushSQLError(e.toString());
			SQLLogger.log("error:"+e.toString());
			throw e ;
		}
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see java.sql.Statement#executeUpdate(java.lang.String)
	 */
	public int executeUpdate(String sql) throws SQLException 
	{
		try
		{
			SQLLogger.log(sql);
			int ret =  mPst.executeUpdate( sql);
			SQLLogger.log("Success");
			return ret ;
		}
		catch(SQLException e)
		{
			GSBaseDAO.pushSQLError(e.toString());
			SQLLogger.log("error:"+e.toString());
			throw e ;
		}
	}



	/* (non-Javadoc)
	 * @see java.sql.Statement#getMaxFieldSize()
	 */
	public int getMaxFieldSize() throws SQLException {
		// TODO Auto-generated method stub
		return mPst.getMaxFieldSize();
	}

	/* (non-Javadoc)
	 * @see java.sql.Statement#setMaxFieldSize(int)
	 */
	public void setMaxFieldSize(int max) throws SQLException {
		// TODO Auto-generated method stub
		mPst.setMaxFieldSize( max) ;
	}

	/* (non-Javadoc)
	 * @see java.sql.Statement#getMaxRows()
	 */
	public int getMaxRows() throws SQLException {
		// TODO Auto-generated method stub
		return mPst.getMaxRows();
	}

	/* (non-Javadoc)
	 * @see java.sql.Statement#setMaxRows(int)
	 */
	public void setMaxRows(int max) throws SQLException {
		// TODO Auto-generated method stub
		mPst.setMaxRows( max) ;
	}

	/* (non-Javadoc)
	 * @see java.sql.Statement#setEscapeProcessing(boolean)
	 */
	public void setEscapeProcessing(boolean enable) throws SQLException {
		// TODO Auto-generated method stub
		mPst.setEscapeProcessing( enable);
	}

	/* (non-Javadoc)
	 * @see java.sql.Statement#getQueryTimeout()
	 */
	public int getQueryTimeout() throws SQLException {
		// TODO Auto-generated method stub
		return mPst.getQueryTimeout();
	}

	/* (non-Javadoc)
	 * @see java.sql.Statement#setQueryTimeout(int)
	 */
	public void setQueryTimeout(int seconds) throws SQLException {
		// TODO Auto-generated method stub
		mPst.setQueryTimeout( seconds) ;
	}

	/* (non-Javadoc)
	 * @see java.sql.Statement#cancel()
	 */
	public void cancel() throws SQLException {
		// TODO Auto-generated method stub
		mPst.cancel();
	}

	/* (non-Javadoc)
	 * @see java.sql.Statement#getWarnings()
	 */
	public SQLWarning getWarnings() throws SQLException {
		// TODO Auto-generated method stub
		return mPst.getWarnings();
	}

	/* (non-Javadoc)
	 * @see java.sql.Statement#clearWarnings()
	 */
	public void clearWarnings() throws SQLException {
		// TODO Auto-generated method stub
		mPst.clearWarnings();
	}

	/* (non-Javadoc)
	 * @see java.sql.Statement#setCursorName(java.lang.String)
	 */
	public void setCursorName(String name) throws SQLException {
		// TODO Auto-generated method stub
		mPst.setCursorName( name);
	}

	/* (non-Javadoc)
	 * @see java.sql.Statement#execute(java.lang.String)
	 */
	public boolean execute(String sql) throws SQLException {
		// TODO Auto-generated method stub
		
		try
		{
			SQLLogger.log(sql);
			
			boolean ret = mPst.execute( sql) ;
			
			SQLLogger.log("Success");
			
			return ret ;
		}
		catch(SQLException e)
		{
			GSBaseDAO.pushSQLError(e.toString());
			SQLLogger.log("error:"+e.toString());
			throw e ;
		}
	}

	/* (non-Javadoc)
	 * @see java.sql.Statement#getResultSet()
	 */
	public ResultSet getResultSet() throws SQLException 
	{
		// TODO Auto-generated method stub
		try
		{
			MyResultSet ret =  new MyResultSet(mPst.getResultSet());
			SQLLogger.log("Success");
			return ret ;
		}
		catch(SQLException e)
		{
			GSBaseDAO.pushSQLError(e.toString());
			SQLLogger.log("error:"+e.toString());
			throw e ;
		}
	}

	/* (non-Javadoc)
	 * @see java.sql.Statement#getUpdateCount()
	 */
	public int getUpdateCount() throws SQLException {
		// TODO Auto-generated method stub
		return mPst.getUpdateCount() ;
	}

	/* (non-Javadoc)
	 * @see java.sql.Statement#getMoreResults()
	 */
	public boolean getMoreResults() throws SQLException {
		// TODO Auto-generated method stub
		return mPst.getMoreResults();
	}

	/* (non-Javadoc)
	 * @see java.sql.Statement#setFetchDirection(int)
	 */
	public void setFetchDirection(int direction) throws SQLException {
		// TODO Auto-generated method stub
		mPst.setFetchDirection( direction);
	}

	/* (non-Javadoc)
	 * @see java.sql.Statement#getFetchDirection()
	 */
	public int getFetchDirection() throws SQLException {
		// TODO Auto-generated method stub
		return mPst.getFetchDirection();
	}

	/* (non-Javadoc)
	 * @see java.sql.Statement#setFetchSize(int)
	 */
	public void setFetchSize(int rows) throws SQLException {
		// TODO Auto-generated method stub
		mPst.setFetchSize( rows);
	}

	/* (non-Javadoc)
	 * @see java.sql.Statement#getFetchSize()
	 */
	public int getFetchSize() throws SQLException {
		// TODO Auto-generated method stub
		return mPst.getFetchSize();
	}

	/* (non-Javadoc)
	 * @see java.sql.Statement#getResultSetConcurrency()
	 */
	public int getResultSetConcurrency() throws SQLException {
		// TODO Auto-generated method stub
		return mPst.getResultSetConcurrency();
	}

	/* (non-Javadoc)
	 * @see java.sql.Statement#getResultSetType()
	 */
	public int getResultSetType() throws SQLException {
		// TODO Auto-generated method stub
		return mPst.getResultSetType();
	}

	/* (non-Javadoc)
	 * @see java.sql.Statement#addBatch(java.lang.String)
	 */
	public void addBatch(String sql) throws SQLException {
		// TODO Auto-generated method stub
		try
		{
			SQLLogger.log(sql);
			mPst.addBatch( sql);
			SQLLogger.log("Success");
		}
		catch(SQLException e)
		{
			GSBaseDAO.pushSQLError(e.toString());
			SQLLogger.log("error:"+e.toString());
			throw e ;
		}
		
	}

	/* (non-Javadoc)
	 * @see java.sql.Statement#clearBatch()
	 */
	public void clearBatch() throws SQLException {
		// TODO Auto-generated method stub
		mPst. clearBatch();
	}

	/* (non-Javadoc)
	 * @see java.sql.Statement#executeBatch()
	 */
	public int[] executeBatch() throws SQLException {
		// TODO Auto-generated method stub
		try
		{
			int[] ret =  mPst.executeBatch() ;
			SQLLogger.log("Success");
			return ret ;
		}
		catch(SQLException e)
		{
			GSBaseDAO.pushSQLError(e.toString());
			SQLLogger.log("error:"+e.toString());
			throw e ;
		}
	}

	/* (non-Javadoc)
	 * @see java.sql.Statement#getConnection()
	 */
	public Connection getConnection() throws SQLException 
	{
		// TODO Auto-generated method stub
		return mCon ;
	}

	/* (non-Javadoc)
	 * @see java.sql.Statement#getMoreResults(int)
	 */
	public boolean getMoreResults(int current) throws SQLException {
		// TODO Auto-generated method stub
		return mPst.getMoreResults( current);
	}

	/* (non-Javadoc)
	 * @see java.sql.Statement#getGeneratedKeys()
	 */
	public ResultSet getGeneratedKeys() throws SQLException {
		// TODO Auto-generated method stub
		return mPst.getGeneratedKeys();
	}

	/* (non-Javadoc)
	 * @see java.sql.Statement#executeUpdate(java.lang.String, int)
	 */
	public int executeUpdate(String sql, int autoGeneratedKeys)
		throws SQLException {
		// TODO Auto-generated method stub
		
		try
		{
			SQLLogger.log(sql);
			int ret = mPst.executeUpdate( sql,  autoGeneratedKeys);
			SQLLogger.log("Success");
			return ret ;
		}
		catch(SQLException e)
		{
			GSBaseDAO.pushSQLError(e.toString());
			SQLLogger.log("error:"+e.toString());
			throw e ;
		}
	}

	/* (non-Javadoc)
	 * @see java.sql.Statement#executeUpdate(java.lang.String, int[])
	 */
	public int executeUpdate(String sql, int[] columnIndexes)
		throws SQLException {
		// TODO Auto-generated method stub
		
		try
		{
			SQLLogger.log(sql);
			int ret  = mPst.executeUpdate( sql,  columnIndexes);
			SQLLogger.log("Success");
			return ret ;
		}
		catch(SQLException e)
		{
			GSBaseDAO.pushSQLError(e.toString());
			throw e ;
		}
	}

	/* (non-Javadoc)
	 * @see java.sql.Statement#executeUpdate(java.lang.String, java.lang.String[])
	 */
	public int executeUpdate(String sql, String[] columnNames)
		throws SQLException {
		// TODO Auto-generated method stub
		try
		{
			SQLLogger.log(sql);
			int ret= mPst.executeUpdate( sql,  columnNames);
			SQLLogger.log("Success");
			return ret ;
	
		}
		catch(SQLException e)
		{
			GSBaseDAO.pushSQLError(e.toString());
			SQLLogger.log("error:"+e.toString());
			throw e ;
		}
	}

	/* (non-Javadoc)
	 * @see java.sql.Statement#execute(java.lang.String, int)
	 */
	public boolean execute(String sql, int autoGeneratedKeys)
		throws SQLException {
		// TODO Auto-generated method stub
		
		try
		{
			SQLLogger.log(sql);
			boolean ret =  mPst.execute( sql,  autoGeneratedKeys);
			SQLLogger.log("Success");
			return ret ;
		}
		catch(SQLException e)
		{
			GSBaseDAO.pushSQLError(e.toString());
			SQLLogger.log("error:"+e.toString());
			throw e ;
		}
	}

	/* (non-Javadoc)
	 * @see java.sql.Statement#execute(java.lang.String, int[])
	 */
	public boolean execute(String sql, int[] columnIndexes)
		throws SQLException {
		// TODO Auto-generated method stub
		
		try
		{
			SQLLogger.log(sql);
			boolean ret = mPst.execute( sql,  columnIndexes);
			SQLLogger.log("Success");
			return ret ;
		}
		catch(SQLException e)
		{
			GSBaseDAO.pushSQLError(e.toString());
			SQLLogger.log("error:"+e.toString());
			throw e ;
		}
	}

	/* (non-Javadoc)
	 * @see java.sql.Statement#execute(java.lang.String, java.lang.String[])
	 */
	public boolean execute(String sql, String[] columnNames)
		throws SQLException {
		// TODO Auto-generated method stub
		
		try
		{
			SQLLogger.log(sql);
			boolean ret = mPst.execute( sql,  columnNames);
			SQLLogger.log("Success");
			return ret ;
		}
		catch(SQLException e)
		{
			GSBaseDAO.pushSQLError(e.toString());
			SQLLogger.log("error:"+e.toString());
			throw e ;
		}
	}

	/* (non-Javadoc)
	 * @see java.sql.Statement#getResultSetHoldability()
	 */
	public int getResultSetHoldability() throws SQLException {
		// TODO Auto-generated method stub
		return mPst.getResultSetHoldability() ;
	}

}
